#!/usr/bin/python

import threading
import mutex
import time

def main():
    stdoutMutex = mutex.mutex()

    while True:
        stdoutMutex.lock(A, stdoutMutex)
        stdoutMutex.lock(B, stdoutMutex)

def A(mutex):
    print "A"
    print "B"
    print "C"
    mutex.unlock()

def B(mutex):
    print "1"
    print "2"
    print "3"
    mutex.unlock()

if __name__ == '__main__':
    main()

